package fileOP

import (
	"blogdemo/gin/errmsg"
	"fmt"
	"github.com/qiniu/go-sdk/v7/auth/qbox"
	"github.com/qiniu/go-sdk/v7/storage"
)

// Delete 删除七牛云上的文件
func Delete(theKey string) int {
	// 构建BucketManager对象
	mac := qbox.NewMac(AccessKey, SecretKey)
	cfg := storage.Config{
		Zone:          &storage.ZoneHuanan,
		UseCdnDomains: false,
		UseHTTPS:      false,
	}
	bucketManager := storage.NewBucketManager(mac, &cfg)

	// 删除操作
	bucket := Bucket
	//key := strings.Trim(url, Bucket)
	fmt.Println(theKey)
	err := bucketManager.Delete(bucket, theKey)
	if err != nil {
		return errmsg.FAIL
	}
	return errmsg.SUCCESS
}
